package com.star.wellconnect;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.star.wellconnect.appts.ApptFragment;
import com.star.wellconnect.profile.HomeFragment;

public class WCFragmentPagerAdapter extends FragmentPagerAdapter {
	private String[] pages;
	
	public WCFragmentPagerAdapter(FragmentManager fm, String[] pages) {
		super(fm);
		this.pages = pages;
	}

	@Override
	public Fragment getItem(int position) {
        switch(position){
        case 0:
        	return new HomeFragment();
        case 1:
        	return new ApptFragment();
        case 2:
        	return new MoodFragment(); 	
        default:
        	Fragment fragment = new DemoObjectFragment();
            Bundle args = new Bundle();
            // Our object is just an integer :-P
            args.putInt(DemoObjectFragment.ARG_OBJECT, position + 1);
            fragment.setArguments(args);
            return fragment;
        }
	}

	@Override
	public int getCount() {
		return pages.length;
	}
	
	@Override
	public CharSequence getPageTitle(int position){
		return (CharSequence) pages[position];
	}
	
	public static class DemoObjectFragment extends Fragment {
	    public static final String ARG_OBJECT = "object";

	    @Override
	    public View onCreateView(LayoutInflater inflater,
	            ViewGroup container, Bundle savedInstanceState) {
	        // The last two arguments ensure LayoutParams are inflated
	        // properly.
	        View rootView = inflater.inflate(
	                R.layout.fragment_collection_object, container, false);
	        Bundle args = getArguments();
	        ((TextView) rootView.findViewById(android.R.id.text1)).setText(
	                Integer.toString(args.getInt(ARG_OBJECT)));
	        return rootView;
	    }
	}
}
